<template>
  <PanelStatistics :recharge="recharge" :pay="pay" :withdraw="withdraw" :loading="loading" />
</template>
<script setup>
import { ref, reactive } from "vue";
import PanelStatistics from "./components/PanelStatistics.vue";
import { GetRecharge, GetWithdraw, GetPayment } from "@/api/dashboard/index";

const loading = ref(true);
const recharge = reactive({
  total_amount: 0,
  total_count: 0,
  freeze_amount: 0,
  today_amount: 0,
  today_count: 0,
  symbol: "",
});
const pay = reactive({
  total_amount: 0,
  total_count: 0,
  today_amount: 0,
  today_count: 0,
  symbol: "",
});
const withdraw = reactive({
  total_amount: 0,
  total_count: 0,
  today_amount: 0,
  today_count: 0,
  symbol: "",
});

const getStatisticsData = async () => {
  try {
    loading.value = true;
    const rechargeData = await GetRecharge();
    recharge.symbol = rechargeData.symbol;
    recharge.total_amount = parseFloat(rechargeData.total_amount);
    recharge.total_count = parseFloat(rechargeData.total_count);
    recharge.freeze_amount = parseFloat(rechargeData.freeze_amount);
    recharge.today_amount = parseFloat(rechargeData.today_amount);
    recharge.today_count = parseFloat(rechargeData.today_count);
//    const payData = await GetPayment();
//    pay.symbol = payData.symbol;
//
//    pay.total_amount = parseFloat(payData.total_amount);
//    pay.total_count = parseFloat(payData.total_count);
//    pay.today_amount = parseFloat(payData.today_amount);
//    pay.today_count = parseFloat(payData.today_count);
    const withdrawData = await GetWithdraw();
    withdraw.symbol = withdrawData.symbol;

    withdraw.total_amount = parseFloat(withdrawData.total_amount);
    withdraw.total_count = parseFloat(withdrawData.total_count);
    withdraw.today_amount = parseFloat(withdrawData.today_amount);
    withdraw.today_count = parseFloat(withdrawData.today_count);

    loading.value = false;
  } catch (error) {
    loading.value = false;
  }
};

getStatisticsData();
</script>
